package com.shaw.server;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;

import org.hibernate.ejb.Ejb3Configuration;

import com.shaw.client.MailService;
import com.shaw.client.UserEntity;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;

public class MailServiceImpl extends RemoteServiceServlet implements MailService {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private static EntityManagerFactory emf;
	static{
		Ejb3Configuration ejb3Configuration=new Ejb3Configuration();
		ejb3Configuration.addAnnotatedClass(UserEntity.class);
		emf=ejb3Configuration.buildEntityManagerFactory();
		
		
	}

	public boolean isLoginBoolean(String username, String password) {

		EntityManager eManager=emf.createEntityManager();
		UserEntity uEntity=eManager.find(UserEntity.class, username);
		if(uEntity != null)
		{
			return password==uEntity.getPassword() ;
		}else {
			return false;
		}
		
	}
}
